package com.jdk.learn;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * Created by baiguantao on 2017/4/21.
 *  测试map下的Entry使用
 */
public class MapTest {
    public static void main(String[] args) {
        Map<String,Object> map=new LinkedHashMap<String, Object>();
        map.put("1","1");
        map.put("1","1");
        map.put("2","1");
        //只获取不重复的键
        Set<String> strings=map.keySet();
        System.out.println(strings);//[1, 2]
        Set<Map.Entry<String,Object>> entry=map.entrySet();
        System.out.println(entry);//[1=1, 2=1]
        for (Map.Entry<String,Object> one:entry) {
            System.out.print("key----"+one.getKey());
            System.out.print("value-----"+one.getValue()+"\n");
        }
        /**
         * result --->
         key----1value-----1
         key----2value-----1
         */

    }
}
